const path = require("path");

const PATHS = {
	app:path.join(__dirname,"./src/index.js"),
	build:path.join(__dirname,"dist"),
	publicPath:"/"
};

const webpack = require("webpack");
const htmlPlugin = require("html-webpack-plugin");
const CleanWebpackPlugin = require("clean-webpack-plugin");

module.exports= {
			entry: {
				main: './src/index.js',
			},
			mode: "development",
			output: {
				path: PATHS.build,
				filename: "[name].[hash:16].js",
				publicPath:PATHS.publicPath,
			},

			devServer: {
		        historyApiFallback: true,
		        contentBase:path.resolve(__dirname,'src'),
		        quiet: false, //控制台中不输出打包的信息
		        noInfo: false,
		        inline: true, //开启页面自动刷新,
		        hotOnly:true,

		   //     publicPath:PATHS.publicPath,
		        stats:'errors-only',
		        lazy: false, //不启动懒加载
		        compress:true,
		        progress: false, //显示打包的进度
		        overlay:{  //把编译的错误显示在浏览器上
		            errors:true,
		            warnings:true,
		        },
		        watchOptions: {
		            aggregateTimeout: 300,
		            ignored: /node_modules/,
		        },
		        port: '8099', //设置端口号
		        //其实很简单的，只要配置这个参数就可以了
		      /*  proxy: {
		            '/INFManage': {
		                target: 'http://localhost:8080',
		                secure: false,
		                changeOrigin:true,
		            }
		        }*/

    		},
    		plugins:[
				  new webpack.HotModuleReplacementPlugin(),
    			  new webpack.NamedModulesPlugin(),
				  new htmlPlugin({
				  	title:"test"
				  }),	
				  new CleanWebpackPlugin(['dist']),
			],
		}


/*module.exports=function(env,argv){



		return {
			entry: {
				main: './src/index.js',
			},
			mode: "development",
			output: {
				path: PATHS.build,
				filename: '[name].boundle.js',
				publicPath:PATHS.publicPath,
			},

			devServer: {
		        historyApiFallback: true,
		     //   contentBase:path.resolve(__dirname,'src'),
		        quiet: false, //控制台中不输出打包的信息
		        noInfo: false,
		        inline: true, //开启页面自动刷新,
		        hotOnly:true,
		        publicPath:PATHS.publicPath,
		        stats:'errors-only',
		        lazy: false, //不启动懒加载
		        compress:true,
		        progress: false, //显示打包的进度
		        overlay:{  //把编译的错误显示在浏览器上
		            errors:true,
		            warnings:true,
		        },
		        watchOptions: {
		            aggregateTimeout: 300
		        },
		        port: '8099', //设置端口号
		        //其实很简单的，只要配置这个参数就可以了
		       proxy: {
		            '/INFManage': {
		                target: 'http://localhost:8080',
		                secure: false,
		                changeOrigin:true,
		            }
		        }

    		},
    		plugins:[
				  new webpack.HotModuleReplacementPlugin(),
    			  new webpack.NamedModulesPlugin(),
				  new htmlPlugin({
				  	title:"test"
				  }),	
				  new CleanWebpackPlugin(['dist']),
			],
		};
}*/